home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Amiga Plus 1995 #5 & #6
/
Amiga Plus CD - 1995 - No. 5 and 6.iso
/
pd
/
netz
/
term
/
extras
/
source
/
term-source.lha
/
ModemPanel.c
< prev
next >
Wrap
C/C++ Source or Header
|
1995-06-19
|
13KB
|
565 lines
/*
** ModemPanel.c
**
** Editing panel for modem configuration
**
** Copyright © 1990-1995 by Olaf `Olsen' Barthel
** All Rights Reserved
*/
#include "termGlobal.h"
enum { GAD_LIMIT_MACRO=1000,GAD_DIAL_PREFIX,GAD_DIAL_SUFFIX,
GAD_DIAL_MODE,GAD_USE,GAD_CANCEL,GAD_DEFAULT,
GAD_PAGER,GAD_PAGEGROUP,GAD_INTER_DIAL_DELAY,
};
STATIC UBYTE * __saveds
ShowDialRetries(struct Gadget *SomeGadget,WORD Level)
{
if(Level < 0)
return(LocaleString(MSG_DIAL_RETRIES_UNLIMITED_TXT));
else
{
STATIC UBYTE __far Buffer[10];
SPrintf(Buffer,"%ld",Level);
return(Buffer);
}
}
STATIC UBYTE * __saveds
ShowHours(struct Gadget *SomeGadget,WORD Level)
{
STATIC UBYTE __far Buffer[15];
SPrintf(Buffer,LocaleString(MSG_GLOBAL_SHOW_HOURS_TXT),Level / 60,Level % 60);
return(Buffer);
}
STATIC UBYTE * __saveds
ShowSeconds(struct Gadget *SomeGadget,WORD Level)
{
STATIC UBYTE __far Buffer[15];
SPrintf(Buffer,LocaleString(MSG_GLOBAL_SHOW_MINUTES_TXT),Level / 60,Level % 60);
return(Buffer);
}
BYTE __regargs
ModemPanel(struct Configuration *Config,BYTE *Default)
{
STATIC LONG PageTitleID[6] =
{
MSG_V36_0110,
MSG_V36_0111,
MSG_V36_0112,
MSG_V36_0116,
MSG_V36_0118,
-1
};
STATIC BYTE InitialPage = 0;
struct LayoutHandle *Handle;
BYTE Cancel = FALSE;
STRPTR PageTitle[6];
LocalizeStringTable(PageTitle,PageTitleID);
SaveConfig(Config,PrivateConfig);
if(Handle = LT_CreateHandleTags(Window -> WScreen,
LH_LocaleHook, &LocaleHook,
LH_ExitFlush, FALSE,
TAG_DONE))
{
struct Window *PanelWindow;
LT_New(Handle,
LA_Type, VERTICAL_KIND,
TAG_DONE);
{
LT_New(Handle,
LA_Type,VERTICAL_KIND,
TAG_DONE);
{
LT_New(Handle,
LA_Type, CYCLE_KIND,
LA_ID, GAD_PAGER,
LA_LabelID, MSG_XFER_PAGE_TXT,
GTCY_Labels, PageTitle,
LACY_AutoPageID,GAD_PAGEGROUP,
LACY_TabKey, TRUE,
LA_BYTE, &InitialPage,
TAG_DONE);
LT_EndGroup(Handle);
}
LT_New(Handle,
LA_Type, VERTICAL_KIND,
LA_ID, GAD_PAGEGROUP,
LAGR_Frame, TRUE,
LAGR_ActivePage,InitialPage,
TAG_DONE);
{
LT_New(Handle,
LA_Type, VERTICAL_KIND,
TAG_DONE);
{
LT_New(Handle,
LA_Type, STRING_KIND,
LA_LabelID, MSG_MODEMPANEL_MODEM_INIT_STRING_GAD,
LA_STRPTR, Config -> ModemConfig -> ModemInit,
LA_Chars, 20,
GTST_MaxChars, 79,
TAG_DONE);
LT_New(Handle,
LA_Type, STRING_KIND,
LA_LabelID, MSG_MODEMPANEL_MODEM_EXIT_STRING_GAD,
LA_STRPTR, Config -> ModemConfig -> ModemExit,
GTST_MaxChars, 79,
TAG_DONE);
LT_New(Handle,
LA_Type, STRING_KIND,
LA_LabelID, MSG_MODEMPANEL_MODEM_HANGUP_STRING_GAD,
LA_STRPTR, Config -> ModemConfig -> ModemHangup,
GTST_MaxChars, 79,
TAG_DONE);
LT_New(Handle,
LA_Type, XBAR_KIND,
TAG_DONE);
LT_New(Handle,
LA_Type, INTEGER_KIND,
LA_LabelID, MSG_COMMAND_SEND_DELAY_TXT,
LA_LONG, &Config -> ModemConfig -> CharSendDelay,
LAIN_Min, 0,
LAIN_UseIncrementers, TRUE,
TAG_DONE);
LT_EndGroup(Handle);
}
LT_New(Handle,
LA_Type, VERTICAL_KIND,
TAG_DONE);
{
LT_New(Handle,
LA_Type, STRING_KIND,
LA_LabelID, MSG_MODEMPANEL_NO_CARRIER_STRING_GAD,
LA_STRPTR, Config -> ModemConfig -> NoCarrier,
LA_Chars, 20,
GTST_MaxChars, 15,
TAG_DONE);
LT_New(Handle,
LA_Type, STRING_KIND,
LA_LabelID, MSG_MODEMPANEL_NO_DIALTONE_STRING_GAD,
LA_STRPTR, Config -> ModemConfig -> NoDialTone,
GTST_MaxChars, 15,
TAG_DONE);
LT_New(Handle,
LA_Type, STRING_KIND,
LA_LabelID, MSG_MODEMPANEL_CONNECT_STRING_GAD,
LA_STRPTR, Config -> ModemConfig -> Connect,
GTST_MaxChars, 15,
TAG_DONE);
LT_New(Handle,
LA_Type, STRING_KIND,
LA_LabelID, MSG_MODEMPANEL_VOICE_STRING_GAD,
LA_STRPTR, Config -> ModemConfig -> Voice,
GTST_MaxChars, 15,
TAG_DONE);
LT_New(Handle,
LA_Type, STRING_KIND,
LA_LabelID, MSG_MODEMPANEL_RING_STRING_GAD,
LA_STRPTR, Config -> ModemConfig -> Ring,
GTST_MaxChars, 15,
TAG_DONE);
LT_New(Handle,
LA_Type, STRING_KIND,
LA_LabelID, MSG_MODEMPANEL_BUSY_STRING_GAD,
LA_STRPTR, Config -> ModemConfig -> Busy,
GTST_MaxChars, 15,
TAG_DONE);
LT_New(Handle,
LA_Type, STRING_KIND,
LA_LabelID, MSG_MODEMPANEL_OK_STRING_GAD,
LA_STRPTR, Config -> ModemConfig -> Ok,
GTST_MaxChars, 15,
TAG_DONE);
LT_New(Handle,
LA_Type, STRING_KIND,
LA_LabelID, MSG_MODEMPANEL_ERROR_STRING_GAD,
LA_STRPTR, Config -> ModemConfig -> Error,
GTST_MaxChars, 15,
TAG_DONE);
LT_EndGroup(Handle);
}
LT_New(Handle,
LA_Type, VERTICAL_KIND,
TAG_DONE);
{
BOOL NotFound = TRUE;
WORD i;
for(i = 0 ; NotFound && i < strlen(Config -> ModemConfig -> DialPrefix) - 1 ; i++)
{
if(Config -> ModemConfig -> DialPrefix[i] == '\\' && ToUpper(Config -> ModemConfig -> DialPrefix[i + 1]) == 'W')
NotFound = FALSE;
}
for(i = 0 ; NotFound && i < strlen(Config -> ModemConfig -> DialSuffix) - 1 ; i++)
{
if(Config -> ModemConfig -> DialSuffix[i] == '\\' && ToUpper(Config -> ModemConfig -> DialSuffix[i + 1]) == 'W')
NotFound = FALSE;
}
LT_New(Handle,
LA_Type, STRING_KIND,
LA_LabelID, MSG_MODEMPANEL_DIAL_PREFIX_GAD,
LA_STRPTR, Config -> ModemConfig -> DialPrefix,
LA_Chars, 20,
LA_ID, GAD_DIAL_PREFIX,
GTST_MaxChars, 79,
TAG_DONE);
LT_New(Handle,
LA_Type, STRING_KIND,
LA_LabelID, MSG_MODEMPANEL_DIAL_SUFFIX_GAD,
LA_STRPTR, Config -> ModemConfig -> DialSuffix,
LA_ID, GAD_DIAL_SUFFIX,
GTST_MaxChars, 79,
TAG_DONE);
LT_New(Handle,
LA_Type, CYCLE_KIND,
LA_LabelID, MSG_DIALMODE2_GAD,
LA_BYTE, &Config -> ModemConfig -> DialMode,
LA_ID, GAD_DIAL_MODE,
LACY_FirstLabel, MSG_DIALMODE1_TXT,
LACY_LastLabel, MSG_DIALMODE2_TXT,
GA_Disabled, NotFound,
TAG_DONE);
LT_New(Handle,
LA_Type, XBAR_KIND,
TAG_DONE);
LT_New(Handle,
LA_Type, SliderType,
LA_LabelID, MSG_MODEMPANEL_REDIAL_DELAY_GAD,
LA_LONG, &Config -> ModemConfig -> RedialDelay,
GTSL_Min, 0,
GTSL_Max, 60 * 60,
GTSL_DispFunc, ShowSeconds,
GTSL_LevelFormat, "%s",
TAG_DONE);
LT_New(Handle,
LA_Type, SliderType,
LA_LabelID, MSG_MODEMPANEL_DIAL_RETRIES_GAD,
LA_LONG, &Config -> ModemConfig -> DialRetries,
GTSL_DispFunc, ShowDialRetries,
GTSL_Min, -1,
GTSL_Max, 1000,
GTSL_LevelFormat, "%s",
TAG_DONE);
LT_New(Handle,
LA_Type, SliderType,
LA_LabelID, MSG_MODEMPANEL_DIAL_TIMEOUT_GAD,
LA_LONG, &Config -> ModemConfig -> DialTimeout,
GTSL_Min, 0,
GTSL_Max, 1800,
GTSL_DispFunc, ShowSeconds,
GTSL_LevelFormat, "%s",
TAG_DONE);
LT_New(Handle,
LA_Type, SliderType,
LA_LabelID, MSG_INTER_DIAL_DELAY_TXT,
LA_LONG, &Config -> ModemConfig -> InterDialDelay,
GTSL_Min, 0,
GTSL_Max, 1800,
GTSL_DispFunc, ShowSeconds,
GTSL_LevelFormat, "%s",
TAG_DONE);
LT_New(Handle,
LA_Type, CHECKBOX_KIND,
LA_LabelID, MSG_VERBOSE_DIALING_TXT,
LA_BYTE, &Config -> ModemConfig -> VerboseDialing,
TAG_DONE);
LT_New(Handle,
LA_Type, XBAR_KIND,
TAG_DONE);
LT_New(Handle,
LA_Type, CHECKBOX_KIND,
LA_LabelID, MSG_MODEMPANEL_CONNECT_AUTO_BAUD_GAD,
LA_BYTE, &Config -> ModemConfig -> ConnectAutoBaud,
TAG_DONE);
LT_New(Handle,
LA_Type, CHECKBOX_KIND,
LA_LabelID, MSG_MODEMPANEL_NOCARRIER_IS_BUSY_GAD,
LA_BYTE, &Config -> ModemConfig -> NoCarrierIsBusy,
TAG_DONE);
LT_New(Handle,
LA_Type, CHECKBOX_KIND,
LA_LabelID, MSG_MODEMPANEL_ABORT_HANGS_UP_TXT,
LA_BYTE, &Config -> ModemConfig -> AbortHangsUp,
TAG_DONE);
LT_New(Handle,
LA_Type, SliderType,
LA_LabelID, MSG_MODEMPANEL_TIME_TO_CONNECT_GAD,
LA_LONG, &Config -> ModemConfig -> TimeToConnect,
LA_Chars, 8,
GTSL_Min, 0,
GTSL_Max, 60 * 60,
GTSL_DispFunc, ShowSeconds,
GTSL_LevelFormat, "%s",
TAG_DONE);
LT_EndGroup(Handle);
}
LT_New(Handle,
LA_Type, VERTICAL_KIND,
TAG_DONE);
{
LT_New(Handle,
LA_Type, CHECKBOX_KIND,
LA_LabelID, MSG_MODEMPANEL_DROP_DTR_ON_HANGUP_GAD,
LA_BYTE, &Config -> ModemConfig -> DropDTR,
TAG_DONE);
LT_New(Handle,
LA_Type, CHECKBOX_KIND,
LA_LabelID, MSG_MODEMPANEL_REDIAL_AFTER_HANGUP_GAD,
LA_BYTE, &Config -> ModemConfig -> RedialAfterHangup,
TAG_DONE);
LT_EndGroup(Handle);
}
LT_New(Handle,
LA_Type, VERTICAL_KIND,
TAG_DONE);
{
LT_New(Handle,
LA_Type, SliderType,
LA_LabelID, MSG_MODEMPANEL_CONNECTION_LIMIT_GAD,
LA_WORD, &Config -> ModemConfig -> ConnectLimit,
GTSL_Min, 0,
GTSL_Max, 1440,
GTSL_DispFunc, ShowHours,
GTSL_LevelFormat, "%s",
TAG_DONE);
LT_New(Handle,
LA_Type, STRING_KIND,
LA_LabelID, MSG_MODEMPANEL_LIMIT_MACRO_GAD,
LA_STRPTR, Config -> ModemConfig -> ConnectLimitMacro,
LA_Chars, 20,
LA_ID, GAD_LIMIT_MACRO,
GTST_MaxChars, MAX_FILENAME_LENGTH - 1,
TAG_DONE);
LT_EndGroup(Handle);
}
LT_EndGroup(Handle);
}
LT_New(Handle,
LA_Type, VERTICAL_KIND,
TAG_DONE);
{
LT_New(Handle,LA_Type,XBAR_KIND,LAXB_FullSize,TRUE,TAG_DONE);
LT_EndGroup(Handle);
}
LT_New(Handle,LA_Type,HORIZONTAL_KIND,
LAGR_SameSize, TRUE,
LAGR_Spread, TRUE,
TAG_DONE);
{
LT_New(Handle,
LA_Type, BUTTON_KIND,
LA_LabelID, MSG_GLOBAL_USE_GAD,
LA_ID, GAD_USE,
LABT_ReturnKey, TRUE,
LABT_ExtraFat, TRUE,
TAG_DONE);
if(Default)
{
LT_New(Handle,
LA_Type, BUTTON_KIND,
LA_LabelID, MSG_GLOBAL_DEFAULT_GAD,
LA_ID, GAD_DEFAULT,
LABT_ExtraFat, TRUE,
TAG_DONE);
}
LT_New(Handle,
LA_Type, BUTTON_KIND,
LA_LabelID, MSG_GLOBAL_CANCEL_GAD,
LA_ID, GAD_CANCEL,
LABT_EscKey, TRUE,
LABT_ExtraFat, TRUE,
TAG_DONE);
LT_EndGroup(Handle);
}
LT_EndGroup(Handle);
}
if(PanelWindow = LT_Layout(Handle,LocaleString(MSG_MODEMPANEL_MODEM_PREFERENCES_TXT),NULL,0,0,IDCMP_CLOSEWINDOW,0,
LAWN_HelpHook, &GuideHook,
LAWN_Parent, Window,
WA_DepthGadget, TRUE,
WA_CloseGadget, TRUE,
WA_DragBar, TRUE,
WA_RMBTrap, TRUE,
WA_Activate, TRUE,
TAG_DONE))
{
struct IntuiMessage *Message;
BOOLEAN Done = FALSE;
ULONG MsgClass,
MsgQualifier;
UWORD MsgCode;
struct Gadget *MsgGadget;
WORD i;
BOOL NotFound;
GuideContext(CONTEXT_MODEM);
PushWindow(PanelWindow);
LT_ShowWindow(Handle,TRUE);
do
{
if(Wait(PORTMASK(PanelWindow -> UserPort) | SIG_BREAK) & SIG_BREAK)
{
SaveConfig(PrivateConfig,Config);
break;
}
while(Message = (struct IntuiMessage *)GT_GetIMsg(PanelWindow -> UserPort))
{
MsgClass = Message -> Class;
MsgQualifier = Message -> Qualifier;
MsgCode = Message -> Code;
MsgGadget = (struct Gadget *)Message -> IAddress;
GT_ReplyIMsg(Message);
LT_HandleInput(Handle,MsgQualifier,&MsgClass,&MsgCode,&MsgGadget);
if(MsgClass == IDCMP_CLOSEWINDOW)
{
SaveConfig(PrivateConfig,Config);
Done = TRUE;
}
if(MsgClass == IDCMP_GADGETUP)
{
switch(MsgGadget -> GadgetID)
{
case GAD_DIAL_PREFIX:
case GAD_DIAL_SUFFIX:
case GAD_DIAL_MODE:
for(i = 0, NotFound = TRUE ; NotFound && i < strlen(Config -> ModemConfig -> DialPrefix) - 1 ; i++)
{
if(Config -> ModemConfig -> DialPrefix[i] == '\\' && ToUpper(Config -> ModemConfig -> DialPrefix[i + 1]) == 'W')
NotFound = FALSE;
}
for(i = 0 ; NotFound && i < strlen(Config -> ModemConfig -> DialSuffix) - 1 ; i++)
{
if(Config -> ModemConfig -> DialSuffix[i] == '\\' && ToUpper(Config -> ModemConfig -> DialSuffix[i + 1]) == 'W')
NotFound = FALSE;
}
LT_SetAttributes(Handle,GAD_DIAL_MODE,
GA_Disabled,NotFound,
TAG_DONE);
break;
case GAD_USE:
LT_UpdateStrings(Handle);
Done = TRUE;
break;
case GAD_CANCEL:
SaveConfig(PrivateConfig,Config);
Cancel = Done = TRUE;
break;
case GAD_DEFAULT:
*Default = TRUE;
Done = TRUE;
break;
}
}
}
}
while(!Done);
PopWindow();
}
LT_DeleteHandle(Handle);
}
if(!Cancel && Config -> MiscConfig && Config -> SerialConfig)
{
if(Config -> MiscConfig -> ProtectiveMode && Config -> SerialConfig -> BaudRate >= 4800 && Config -> ModemConfig -> ConnectAutoBaud)
{
if(MyEasyRequest(Window,LocaleString(MSG_AUTOBAUD_TXT),LocaleString(MSG_GLOBAL_YES_NO_TXT)))
Config -> ModemConfig -> ConnectAutoBaud = FALSE;
}
}
if(Default)
return((BYTE)(!Cancel));
else
return((BYTE)memcmp(PrivateConfig -> ModemConfig,Config -> ModemConfig,sizeof(struct ModemSettings)));
}